<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

	<script type="text/javascript" src="<c:url value="/js/project.js" />"></script>
	<script type="text/javascript" src="<c:url value="/js/jquery-1.11.0.js" />"></script>
	<title>Project</title>
	
</head>

<body>

	<h4>
			<span style="color: red">${errorMsg}</span>
	</h4>
	<form:form action="addOrUpdateProject?type=${type }" method="POST" onsubmit="return validate()" class="smart-green">
		<c:if test="${type=='update'}">
							
			<h1>
					Update Project <span>Please fill all the texts in the fields.</span>
			</h1>
		</c:if>
		<c:if test="${type=='insert'}">
							
			<h1>
					Add Project <span>Please fill all the texts in the fields.</span>
			</h1>
		</c:if>
		<div id="errorMsg"></div>
		<table>
							<c:if test="${type=='update'}">
								<form:hidden path="projectId" value="${projectId}" id="projectId"/>
							</c:if>
							<tr>
								<td>Project Name <span style="color: red">* </span>: <form:input  path="projectName" id="projectName" value="${projectName }" class="txtbox"/></td>
							</tr>
							<tr>
								<td>Project Description <span style="color: red">* </span>:</td></tr>
								<tr><td><form:textarea path="projectDescription" rows="10" cols="25" id="projectDescription"></form:textarea>

								</td>
							</tr>
						
							<tr>
						
								<td><input type="text" id="searchName" />
								<input type="button" value="Search" onclick='validateAndShow("${type}")' class="button"/></td>
							</tr>
							<tr>
								<td>
									<c:if test="${type=='insert' }">
										<input type="submit" value="Assign Project" class="button"/>
										<input type="reset" value="Clear" class="button"/>
									</c:if>
									<c:if test="${type=='update' }">
										<input type="submit" value="Update Project" class="button"/>
										<input type="reset" value="Clear" class="button"/>
									</c:if>
								</td>
								<td><a href="back"><img src="<c:url value="/images/backbutton.jpg" />" alt="Back" height="50" width="50" title="Back"></a></td>
							</tr>
							<div id="selectedUsers"></div>
							<tr>
								<td>
									<div id="showUsers"></div> 
									<c:if test="${type=='update' }">
									<script type="text/javascript">displaySelectedUsers("${projectDescription}")
									</script>
									</c:if>

								</td>
							</tr>
			
			</table>
	</form:form>

</body>
</html>